import Vue from "vue";
import Router from "vue-router";
import HmIndex from "@/view/HmIndex.vue";
import HmDetail from "@/view/HmDetail.vue";
import Collect from "@/view/Collect.vue";
import HmArticle from "@/view/HmArticle.vue";
import HmLike from "@/view/HmLike.vue";
import HmUser from "@/view/HmUser.vue";
import NotFound from "@/view/NotFound.vue";
import HmLogin from "@/view/HmLogin.vue";
import HmRegister from "@/view/HmRegister.vue";
import HmRecommend from "@/view/HmRecommend.vue";
import HmNew from "@/view/HmNew.vue";
Vue.use(Router);

const router = new Router({
  mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: HmLogin,
    },
    {
      path: "/register",
      component: HmRegister,
    },
    {
      path: "/detail",
      component: HmDetail,
    },
    {
      path: "/index",
      component: HmIndex,
      children: [
        {
          path: "/",
          redirect: "/index/article",
        },
        {
          path: "/index/article",
          component: HmArticle,
          children: [
            // 默认显示推荐
            {
              path: "/",
              redirect: "/index/article/recommend",
            },
            {
              path: "/index/article/recommend",
              component: HmRecommend,
            },
            {
              path: "/index/article/new",
              component: HmNew,
            },
          ],
        },
        {
          path: "/index/collect",
          component: Collect,
        },
        {
          path: "/index/like",
          component: HmLike,
        },
        {
          path: "/index/user",
          component: HmUser,
        },
      ],
    },
    {
      path: "*",
      component: NotFound,
    },
  ],
});

export default router;
